home *** CD-ROM | disk | FTP | other *** search
/ The Arsenal Files 8 / The Arsenal Files Collection #8 (Arsenal Computer) (1996).ISO / g_quake / chaseroc.zip / CLIENT.QC < prev    next >
Text File  |  1996-09-29  |  35KB  |  1,474 lines

  1.  
  2. // prototypes
  3. void () W_WeaponFrame;
  4. void() W_SetCurrentAmmo;
  5. void() player_pain;
  6. void() player_stand1;
  7. void (vector org) spawn_tfog;
  8. void (vector org, entity death_owner) spawn_tdeath;
  9.  
  10. float    modelindex_eyes, modelindex_player;
  11.  
  12. /*
  13. =============================================================================
  14.  
  15.                 LEVEL CHANGING / INTERMISSION
  16.  
  17. =============================================================================
  18. */
  19.  
  20. float    intermission_running;
  21. float    intermission_exittime;
  22.  
  23. /*QUAKED info_intermission (1 0.5 0.5) (-16 -16 -16) (16 16 16)
  24. This is the camera point for the intermission.
  25. Use mangle instead of angle, so you can set pitch or roll as well as yaw.  'pitch roll yaw'
  26. */
  27. void() info_intermission =
  28. {
  29. };
  30.  
  31.  
  32.  
  33. void() SetChangeParms =
  34. {
  35.     if (self.health <= 0)
  36.     {
  37.         SetNewParms ();
  38.         return;
  39.     }
  40.  
  41. // remove items
  42.     self.items = self.items - (self.items & 
  43.     (IT_KEY1 | IT_KEY2 | IT_INVISIBILITY | IT_INVULNERABILITY | IT_SUIT | IT_QUAD) );
  44.     
  45. // cap super health
  46.     if (self.health > 100)
  47.         self.health = 100;
  48.     if (self.health < 50)
  49.         self.health = 50;
  50.     parm1 = self.items;
  51.     parm2 = self.health;
  52.     parm3 = self.armorvalue;
  53.     if (self.ammo_shells < 25)
  54.         parm4 = 25;
  55.     else
  56.         parm4 = self.ammo_shells;
  57.     parm5 = self.ammo_nails;
  58.     parm6 = self.ammo_rockets;
  59.     parm7 = self.ammo_cells;
  60.     parm8 = self.weapon;
  61.     parm9 = self.armortype * 100;
  62.  
  63.    // ### chase cam ###
  64.    // holds current state of cam and targeter between levels
  65.    if( ! deathmatch && ! coop )
  66.       parm16 = self.speed;
  67.  
  68. };
  69.  
  70. void() SetNewParms =
  71. {
  72.     parm1 = IT_SHOTGUN | IT_AXE;
  73.     parm2 = 100;
  74.     parm3 = 0;
  75.     parm4 = 25;
  76.     parm5 = 0;
  77.     parm6 = 0;
  78.     parm7 = 0;
  79.     parm8 = 1;
  80.     parm9 = 0;
  81.  
  82.    // ### chase cam ###
  83.    // state of cam and targeter held in player.speed
  84.    if( ! deathmatch && ! coop )
  85.       parm16 = 0;
  86.  
  87. };
  88.  
  89. void() DecodeLevelParms =
  90. {
  91.     if (serverflags)
  92.     {
  93.         if (world.model == "maps/start.bsp")
  94.             SetNewParms ();        // take away all stuff on starting new episode
  95.     }
  96.     
  97.     self.items = parm1;
  98.     self.health = parm2;
  99.     self.armorvalue = parm3;
  100.     self.ammo_shells = parm4;
  101.     self.ammo_nails = parm5;
  102.     self.ammo_rockets = parm6;
  103.     self.ammo_cells = parm7;
  104.     self.weapon = parm8;
  105.     self.armortype = parm9 * 0.01;
  106.  
  107.    // ### chase cam ###
  108.    // state of cam and targeter held in player.speed
  109.    if( ! deathmatch && ! coop )
  110.       self.speed = parm16;
  111.  
  112. };
  113.  
  114. /*
  115. ============
  116. FindIntermission
  117.  
  118. Returns the entity to view from
  119. ============
  120. */
  121. entity() FindIntermission =
  122. {
  123.     local    entity spot;
  124.     local    float cyc;
  125.  
  126. // look for info_intermission first
  127.     spot = find (world, classname, "info_intermission");
  128.     if (spot)
  129.     {    // pick a random one
  130.         cyc = random() * 4;
  131.         while (cyc > 1)
  132.         {
  133.             spot = find (spot, classname, "info_intermission");
  134.             if (!spot)
  135.                 spot = find (spot, classname, "info_intermission");
  136.             cyc = cyc - 1;
  137.         }
  138.         return spot;
  139.     }
  140.  
  141. // then look for the start position
  142.     spot = find (world, classname, "info_player_start");
  143.     if (spot)
  144.         return spot;
  145.     
  146. // testinfo_player_start is only found in regioned levels
  147.     spot = find (world, classname, "testplayerstart");
  148.     if (spot)
  149.         return spot;
  150.     
  151.     objerror ("FindIntermission: no spot");
  152. };
  153.  
  154.  
  155. string nextmap;
  156. void() GotoNextMap =
  157. {
  158.     if (cvar("samelevel"))    // if samelevel is set, stay on same level
  159.         changelevel (mapname);
  160.     else
  161.         changelevel (nextmap);
  162. };
  163.  
  164.  
  165. void() ExitIntermission =
  166. {
  167. // skip any text in deathmatch
  168.     if (deathmatch)
  169.     {
  170.         GotoNextMap ();
  171.         return;
  172.     }
  173.     
  174.     intermission_exittime = time + 1;
  175.     intermission_running = intermission_running + 1;
  176.  
  177. //
  178. // run some text if at the end of an episode
  179. //
  180.     if (intermission_running == 2)
  181.     {
  182.         if (world.model == "maps/e1m7.bsp")
  183.         {
  184.             WriteByte (MSG_ALL, SVC_CDTRACK);
  185.             WriteByte (MSG_ALL, 2);
  186.             WriteByte (MSG_ALL, 3);
  187.             if (!cvar("registered"))
  188.             {
  189.                 WriteByte (MSG_ALL, SVC_FINALE);
  190.                 WriteString (MSG_ALL, "As the corpse of the monstrous entity\nChthon sinks back into the lava whence\nit rose, you grip the Rune of Earth\nMagic tightly. Now that you have\nconquered the Dimension of the Doomed,\nrealm of Earth Magic, you are ready to\ncomplete your task in the other three\nhaunted lands of Quake. Or are you? If\nyou don't register Quake, you'll never\nknow what awaits you in the Realm of\nBlack Magic, the Netherworld, and the\nElder World!");
  191.             }
  192.             else
  193.             {
  194.                 WriteByte (MSG_ALL, SVC_FINALE);
  195.                 WriteString (MSG_ALL, "As the corpse of the monstrous entity\nChthon sinks back into the lava whence\nit rose, you grip the Rune of Earth\nMagic tightly. Now that you have\nconquered the Dimension of the Doomed,\nrealm of Earth Magic, you are ready to\ncomplete your task. A Rune of magic\npower lies at the end of each haunted\nland of Quake. Go forth, seek the\ntotality of the four Runes!");
  196.             }
  197.             return;
  198.         }
  199.         else if (world.model == "maps/e2m6.bsp")
  200.         {
  201.             WriteByte (MSG_ALL, SVC_CDTRACK);
  202.             WriteByte (MSG_ALL, 2);
  203.             WriteByte (MSG_ALL, 3);
  204.  
  205.             WriteByte (MSG_ALL, SVC_FINALE);
  206.             WriteString (MSG_ALL, "The Rune of Black Magic throbs evilly in\nyour hand and whispers dark thoughts\ninto your brain. You learn the inmost\nlore of the Hell-Mother; Shub-Niggurath!\nYou now know that she is behind all the\nterrible plotting which has led to so\nmuch death and horror. But she is not\ninviolate! Armed with this Rune, you\nrealize that once all four Runes are\ncombined, the gate to Shub-Niggurath's\nPit will open, and you can face the\nWitch-Goddess herself in her frightful\notherworld cathedral.");
  207.             return;
  208.         }
  209.         else if (world.model == "maps/e3m6.bsp")
  210.         {
  211.             WriteByte (MSG_ALL, SVC_CDTRACK);
  212.             WriteByte (MSG_ALL, 2);
  213.             WriteByte (MSG_ALL, 3);
  214.  
  215.             WriteByte (MSG_ALL, SVC_FINALE);
  216.             WriteString (MSG_ALL, "The charred viscera of diabolic horrors\nbubble viscously as you seize the Rune\nof Hell Magic. Its heat scorches your\nhand, and its terrible secrets blight\nyour mind. Gathering the shreds of your\ncourage, you shake the devil's shackles\nfrom your soul, and become ever more\nhard and determined to destroy the\nhideous creatures whose mere existence\nthreatens the souls and psyches of all\nthe population of Earth.");
  217.             return;
  218.         }
  219.         else if (world.model == "maps/e4m7.bsp")
  220.         {
  221.             WriteByte (MSG_ALL, SVC_CDTRACK);
  222.             WriteByte (MSG_ALL, 2);
  223.             WriteByte (MSG_ALL, 3);
  224.  
  225.             WriteByte (MSG_ALL, SVC_FINALE);
  226.             WriteString (MSG_ALL, "Despite the awful might of the Elder\nWorld, you have achieved the Rune of\nElder Magic, capstone of all types of\narcane wisdom. Beyond good and evil,\nbeyond life and death, the Rune\npulsates, heavy with import. Patient and\npotent, the Elder Being Shub-Niggurath\nweaves her dire plans to clear off all\nlife from the Earth, and bring her own\nfoul offspring to our world! For all the\ndwellers in these nightmare dimensions\nare her descendants! Once all Runes of\nmagic power are united, the energy\nbehind them will blast open the Gateway\nto Shub-Niggurath, and you can travel\nthere to foil the Hell-Mother's plots\nin person.");
  227.             return;
  228.         }
  229.  
  230.         GotoNextMap();
  231.     }
  232.     
  233.     if (intermission_running == 3)
  234.     {
  235.         if (!cvar("registered"))
  236.         {    // shareware episode has been completed, go to sell screen
  237.             WriteByte (MSG_ALL, SVC_SELLSCREEN);
  238.             return;
  239.         }
  240.         
  241.         if ( (serverflags&15) == 15)
  242.         {
  243.             WriteByte (MSG_ALL, SVC_FINALE);
  244.             WriteString (MSG_ALL, "Now, you have all four Runes. You sense\ntremendous invisible forces moving to\nunseal ancient barriers. Shub-Niggurath\nhad hoped to use the Runes Herself to\nclear off the Earth, but now instead,\nyou will use them to enter her home and\nconfront her as an avatar of avenging\nEarth-life. If you defeat her, you will\nbe remembered forever as the savior of\nthe planet. If she conquers, it will be\nas if you had never been born.");
  245.             return;
  246.         }
  247.         
  248.     }
  249.  
  250.     GotoNextMap();
  251. };
  252.  
  253. /*
  254. ============
  255. IntermissionThink
  256.  
  257. When the player presses attack or jump, change to the next level
  258. ============
  259. */
  260. void() IntermissionThink =
  261. {
  262.     if (time < intermission_exittime)
  263.         return;
  264.  
  265.     if (!self.button0 && !self.button1 && !self.button2)
  266.         return;
  267.     
  268.     ExitIntermission ();
  269. };
  270.  
  271. void() execute_changelevel =
  272. {
  273.     local entity    pos;
  274.  
  275.     intermission_running = 1;
  276.     
  277. // enforce a wait time before allowing changelevel
  278.     if (deathmatch)
  279.         intermission_exittime = time + 5;
  280.     else
  281.         intermission_exittime = time + 2;
  282.  
  283.     WriteByte (MSG_ALL, SVC_CDTRACK);
  284.     WriteByte (MSG_ALL, 3);
  285.     WriteByte (MSG_ALL, 3);
  286.     
  287.     pos = FindIntermission ();
  288.  
  289.     other = find (world, classname, "player");
  290.     while (other != world)
  291.     {
  292.         other.view_ofs = '0 0 0';
  293.         other.angles = other.v_angle = pos.mangle;
  294.         other.fixangle = TRUE;        // turn this way immediately
  295.         other.nextthink = time + 0.5;
  296.         other.takedamage = DAMAGE_NO;
  297.         other.solid = SOLID_NOT;
  298.         other.movetype = MOVETYPE_NONE;
  299.         other.modelindex = 0;
  300.         setorigin (other, pos.origin);
  301.         other = find (other, classname, "player");
  302.     }    
  303.  
  304.     WriteByte (MSG_ALL, SVC_INTERMISSION);
  305. };
  306.  
  307.  
  308. void() changelevel_touch =
  309. {
  310.     local entity    pos;
  311.  
  312.     if (other.classname != "player")
  313.         return;
  314.  
  315.     if (cvar("noexit"))
  316.     {
  317.         T_Damage (other, self, self, 50000);
  318.         return;
  319.     }
  320.     bprint (other.netname);
  321.     bprint (" exited the level\n");
  322.     
  323.     nextmap = self.map;
  324.  
  325.     SUB_UseTargets ();
  326.  
  327.     if ( (self.spawnflags & 1) && (deathmatch == 0) )
  328.     {    // NO_INTERMISSION
  329.         GotoNextMap();
  330.         return;
  331.     }
  332.     
  333.     self.touch = SUB_Null;
  334.  
  335. // we can't move people right now, because touch functions are called
  336. // in the middle of C movement code, so set a think time to do it
  337.     self.think = execute_changelevel;
  338.     self.nextthink = time + 0.1;
  339. };
  340.  
  341. /*QUAKED trigger_changelevel (0.5 0.5 0.5) ? NO_INTERMISSION
  342. When the player touches this, he gets sent to the map listed in the "map" variable.  Unless the NO_INTERMISSION flag is set, the view will go to the info_intermission spot and display stats.
  343. */
  344. void() trigger_changelevel =
  345. {
  346.     if (!self.map)
  347.         objerror ("chagnelevel trigger doesn't have map");
  348.     
  349.     InitTrigger ();
  350.     self.touch = changelevel_touch;
  351. };
  352.  
  353.  
  354. /*
  355. =============================================================================
  356.  
  357.                 PLAYER GAME EDGE FUNCTIONS
  358.  
  359. =============================================================================
  360. */
  361.  
  362. void() set_suicide_frame;
  363.  
  364. // called by ClientKill and DeadThink
  365. void() respawn =
  366. {
  367.     if (coop)
  368.     {
  369.         // make a copy of the dead body for appearances sake
  370.         CopyToBodyQue (self);
  371.         // get the spawn parms as they were at level start
  372.         setspawnparms (self);
  373.         // respawn        
  374.         PutClientInServer ();
  375.     }
  376.     else if (deathmatch)
  377.     {
  378.         // make a copy of the dead body for appearances sake
  379.         CopyToBodyQue (self);
  380.         // set default spawn parms
  381.         SetNewParms ();
  382.         // respawn        
  383.         PutClientInServer ();
  384.     }
  385.     else
  386.     {    // restart the entire server
  387.         localcmd ("restart\n");
  388.     }
  389. };
  390.  
  391.  
  392. /*
  393. ============
  394. ClientKill
  395.  
  396. Player entered the suicide command
  397. ============
  398. */
  399. void() ClientKill =
  400. {
  401.     bprint (self.netname);
  402.     bprint (" suicides\n");
  403.     set_suicide_frame ();
  404.     self.modelindex = modelindex_player;
  405.     self.frags = self.frags - 2;    // extra penalty
  406.     respawn ();
  407. };
  408.  
  409. float(vector v) CheckSpawnPoint =
  410. {
  411.     return FALSE;
  412. };
  413.  
  414. /*
  415. ============
  416. SelectSpawnPoint
  417.  
  418. Returns the entity to spawn at
  419. ============
  420. */
  421. entity() SelectSpawnPoint =
  422. {
  423.     local    entity spot;
  424.     
  425. // testinfo_player_start is only found in regioned levels
  426.     spot = find (world, classname, "testplayerstart");
  427.     if (spot)
  428.         return spot;
  429.         
  430. // choose a info_player_deathmatch point
  431.     if (coop)
  432.     {
  433.         lastspawn = find(lastspawn, classname, "info_player_coop");
  434.         if (lastspawn == world)
  435.             lastspawn = find (lastspawn, classname, "info_player_start");
  436.         if (lastspawn != world)
  437.             return lastspawn;
  438.     }
  439.     else if (deathmatch)
  440.     {
  441.         lastspawn = find(lastspawn, classname, "info_player_deathmatch");
  442.         if (lastspawn == world)
  443.             lastspawn = find (lastspawn, classname, "info_player_deathmatch");
  444.         if (lastspawn != world)
  445.             return lastspawn;
  446.     }
  447.  
  448.     if (serverflags)
  449.     {    // return with a rune to start
  450.         spot = find (world, classname, "info_player_start2");
  451.         if (spot)
  452.             return spot;
  453.     }
  454.     
  455.     spot = find (world, classname, "info_player_start");
  456.     if (!spot)
  457.         error ("PutClientInServer: no info_player_start on level");
  458.     
  459.     return spot;
  460. };
  461.  
  462. /*
  463. ===========
  464. PutClientInServer
  465.  
  466. called each time a player is spawned
  467. ============
  468. */
  469. void() DecodeLevelParms;
  470. void() PlayerDie;
  471.  
  472. // ### chase cam mod ###
  473. void() Chase_cam_level_start;
  474.  
  475. void() PutClientInServer =
  476. {
  477.     local    entity spot;
  478.  
  479.     self.classname = "player";
  480.     self.health = 100;
  481.     self.takedamage = DAMAGE_AIM;
  482.     self.solid = SOLID_SLIDEBOX;
  483.     self.movetype = MOVETYPE_WALK;
  484.     self.show_hostile = 0;
  485.     self.max_health = 100;
  486.     self.flags = FL_CLIENT;
  487.     self.air_finished = time + 12;
  488.     self.dmg = 2;           // initial water damage
  489.     self.super_damage_finished = 0;
  490.     self.radsuit_finished = 0;
  491.     self.invisible_finished = 0;
  492.     self.invincible_finished = 0;
  493.     self.effects = 0;
  494.     self.invincible_time = 0;
  495.  
  496.     DecodeLevelParms ();
  497.     
  498.     W_SetCurrentAmmo ();
  499.  
  500.     self.attack_finished = time;
  501.     self.th_pain = player_pain;
  502.     self.th_die = PlayerDie;
  503.     
  504.     self.deadflag = DEAD_NO;
  505. // paustime is set by teleporters to keep the player from moving a while
  506.     self.pausetime = 0;
  507.     
  508.     spot = SelectSpawnPoint ();
  509.  
  510.     self.origin = spot.origin + '0 0 1';
  511.     self.angles = spot.angles;
  512.     self.fixangle = TRUE;        // turn this way immediately
  513.  
  514. // oh, this is a hack!
  515.     setmodel (self, "progs/eyes.mdl");
  516.     modelindex_eyes = self.modelindex;
  517.  
  518.     setmodel (self, "progs/player.mdl");
  519.     modelindex_player = self.modelindex;
  520.  
  521.     setsize (self, VEC_HULL_MIN, VEC_HULL_MAX);
  522.     
  523.     self.view_ofs = '0 0 22';
  524.  
  525.     player_stand1 ();
  526.     
  527.     if (deathmatch || coop)
  528.     {
  529.         makevectors(self.angles);
  530.         spawn_tfog (self.origin + v_forward*20);
  531.     }
  532.  
  533.     spawn_tdeath (self.origin, self);
  534.  
  535.    // ### chase cam mod ###
  536.    // reset view and targeter according to what was set in parm16
  537.    if( ! deathmatch && ! coop )
  538.       Chase_cam_level_start();
  539.  
  540. // *************************************************************************
  541. // **                                          **
  542. // ** M U L T I S K I N  1.1  (start)                                     **
  543. // **                                      **
  544. // *************************************************************************
  545.  
  546.     if (self.skin == 0) centerprint(self, "Mr. Quake himself!"); else
  547.     if (self.skin == 1) centerprint(self, "No time to play with yourself here!"); else
  548.     if (self.skin == 2) centerprint(self, "You're one pretty toad!"); else
  549.     if (self.skin == 3) centerprint(self, "Wow Stormtrooper, you're though!"); else
  550.     if (self.skin == 4) centerprint(self, "Hi Max, looking yellow/blue today!"); else
  551.     if (self.skin == 5) centerprint(self, "You are back!"); else
  552.     if (self.skin == 6) centerprint(self, "Judge Dredd! Let's restore some order!"); else
  553.     if (self.skin == 7) centerprint(self, "Camo! Can't see you, where are you!"); else
  554.     if (self.skin == 8) centerprint(self, "Okay Captain Picard, make it so!"); else
  555.     if (self.skin == 9) centerprint(self, "Whizz whizz.. Wizzard!"); else
  556.     if (self.skin == 10) centerprint(self,"I'm the Predator, you're the prey!"); else
  557.     if (self.skin == 11) centerprint(self,"Welcome Skeleton, looking good!"); else
  558.     if (self.skin == 12) centerprint(self,"Wan-Fu, whoever you are :)"); else
  559.     if (self.skin == 13) centerprint(self,"Oh no, it's Henry Rollins!"); else
  560.     if (self.skin == 14) centerprint(self,"Ooh no, it's She.. eh.. He-Man"); else
  561.     if (self.skin == 15) centerprint(self,"If it isn't Boba, go get Han Solo!"); else
  562.     if (self.skin == 16) centerprint(self,"It's SUPERMAN!"); else
  563.     if (self.skin == 17) centerprint(self,"Protect the innocent, uphold your law"); else
  564.     if (self.skin == 18) centerprint(self,"Why is that symbol on your suit?");
  565.  
  566. // *************************************************************************
  567. // **                                          **
  568. // ** M U L T I S K I N  1.1  (end)                                       **
  569. // **                                      **
  570. // *************************************************************************
  571.  
  572.  
  573.  
  574. };
  575.  
  576.  
  577. /*
  578. =============================================================================
  579.  
  580.                 QUAKED FUNCTIONS
  581.  
  582. =============================================================================
  583. */
  584.  
  585.  
  586. /*QUAKED info_player_start (1 0 0) (-16 -16 -24) (16 16 24)
  587. The normal starting point for a level.
  588. */
  589. void() info_player_start =
  590. {
  591. };
  592.  
  593.  
  594. /*QUAKED info_player_start2 (1 0 0) (-16 -16 -24) (16 16 24)
  595. Only used on start map for the return point from an episode.
  596. */
  597. void() info_player_start2 =
  598. {
  599. };
  600.  
  601.  
  602. /*
  603. saved out by quaked in region mode
  604. */
  605. void() testplayerstart =
  606. {
  607. };
  608.  
  609. /*QUAKED info_player_deathmatch (1 0 1) (-16 -16 -24) (16 16 24)
  610. potential spawning position for deathmatch games
  611. */
  612. void() info_player_deathmatch =
  613. {
  614. };
  615.  
  616. /*QUAKED info_player_coop (1 0 1) (-16 -16 -24) (16 16 24)
  617. potential spawning position for coop games
  618. */
  619. void() info_player_coop =
  620. {
  621. };
  622.  
  623. /*
  624. ===============================================================================
  625.  
  626. RULES
  627.  
  628. ===============================================================================
  629. */
  630.  
  631. /*
  632. go to the next level for deathmatch
  633. only called if a time or frag limit has expired
  634. */
  635. void() NextLevel =
  636. {
  637.     local entity o;
  638.  
  639.     if (mapname == "start")
  640.     {
  641.         if (!cvar("registered"))
  642.         {
  643.             mapname = "e1m1";
  644.         }
  645.         else if (!(serverflags & 1))
  646.         {
  647.             mapname = "e1m1";
  648.             serverflags = serverflags + 1;
  649.         }
  650.         else if (!(serverflags & 2))
  651.         {
  652.             mapname = "e2m1";
  653.             serverflags = serverflags + 2;
  654.         }
  655.         else if (!(serverflags & 4))
  656.         {
  657.             mapname = "e3m1";
  658.             serverflags = serverflags + 4;
  659.         }
  660.         else if (!(serverflags & 8))
  661.         {
  662.             mapname = "e4m1";
  663.             serverflags = serverflags + 8;
  664.         }
  665.         else
  666.         {
  667.             mapname = "start";
  668.             serverflags = serverflags - 15;
  669.         }
  670.  
  671.         o = spawn();
  672.         o.map = mapname;
  673.     }
  674.     else
  675.     {
  676.         // find a trigger changelevel
  677.         o = find(world, classname, "trigger_changelevel");
  678.  
  679.         // go back to start if no trigger_changelevel
  680.         if (!o)
  681.         {
  682.             mapname = "start";
  683.             o = spawn();
  684.             o.map = mapname;
  685.         }
  686.     }
  687.  
  688.     nextmap = o.map;
  689.     gameover = TRUE;
  690.     
  691.     if (o.nextthink < time)
  692.     {
  693.         o.think = execute_changelevel;
  694.         o.nextthink = time + 0.1;
  695.     }
  696. };
  697.  
  698. /*
  699. ============
  700. CheckRules
  701.  
  702. Exit deathmatch games upon conditions
  703. ============
  704. */
  705. void() CheckRules =
  706. {
  707.     local    float        timelimit;
  708.     local    float        fraglimit;
  709.     
  710.     if (gameover)    // someone else quit the game already
  711.         return;
  712.         
  713.     timelimit = cvar("timelimit") * 60;
  714.     fraglimit = cvar("fraglimit");
  715.     
  716.     if (timelimit && time >= timelimit)
  717.     {
  718.         NextLevel ();
  719.         return;
  720.     }
  721.     
  722.     if (fraglimit && self.frags >= fraglimit)
  723.     {
  724.         NextLevel ();
  725.         return;
  726.     }    
  727. };
  728.  
  729. //============================================================================
  730.  
  731. void() PlayerDeathThink =
  732. {
  733.     local entity    old_self;
  734.     local float        forward;
  735.  
  736.     if ((self.flags & FL_ONGROUND))
  737.     {
  738.         forward = vlen (self.velocity);
  739.         forward = forward - 20;
  740.         if (forward <= 0)
  741.             self.velocity = '0 0 0';
  742.         else    
  743.             self.velocity = forward * normalize(self.velocity);
  744.     }
  745.  
  746. // wait for all buttons released
  747.     if (self.deadflag == DEAD_DEAD)
  748.     {
  749.         if (self.button2 || self.button1 || self.button0)
  750.             return;
  751.         self.deadflag = DEAD_RESPAWNABLE;
  752.         return;
  753.     }
  754.  
  755. // wait for any button down
  756.     if (!self.button2 && !self.button1 && !self.button0)
  757.         return;
  758.  
  759.     self.button0 = 0;
  760.     self.button1 = 0;
  761.     self.button2 = 0;
  762.     respawn();
  763. };
  764.  
  765.  
  766. void() PlayerJump =
  767. {
  768.     local vector start, end;
  769.     
  770.     if (self.flags & FL_WATERJUMP)
  771.         return;
  772.     
  773.     if (self.waterlevel >= 2)
  774.     {
  775.         if (self.watertype == CONTENT_WATER)
  776.             self.velocity_z = 100;
  777.         else if (self.watertype == CONTENT_SLIME)
  778.             self.velocity_z = 80;
  779.         else
  780.             self.velocity_z = 50;
  781.  
  782. // play swiming sound
  783.         if (self.swim_flag < time)
  784.         {
  785.             self.swim_flag = time + 1;
  786.             if (random() < 0.5)
  787.                 sound (self, CHAN_BODY, "misc/water1.wav", 1, ATTN_NORM);
  788.             else
  789.                 sound (self, CHAN_BODY, "misc/water2.wav", 1, ATTN_NORM);
  790.         }
  791.  
  792.         return;
  793.     }
  794.  
  795.     if (!(self.flags & FL_ONGROUND))
  796.         return;
  797.  
  798.     if ( !(self.flags & FL_JUMPRELEASED) )
  799.         return;        // don't pogo stick
  800.  
  801.     self.flags = self.flags - (self.flags & FL_JUMPRELEASED);
  802.  
  803.     self.flags = self.flags - FL_ONGROUND;    // don't stairwalk
  804.     
  805.     self.button2 = 0;
  806. // player jumping sound
  807.     sound (self, CHAN_BODY, "player/plyrjmp8.wav", 1, ATTN_NORM);
  808.     self.velocity_z = self.velocity_z + 270;
  809. };
  810.  
  811.  
  812. /*
  813. ===========
  814. WaterMove
  815.  
  816. ============
  817. */
  818. .float    dmgtime;
  819.  
  820. void() WaterMove =
  821. {
  822. //dprint (ftos(self.waterlevel));
  823.     if (self.movetype == MOVETYPE_NOCLIP)
  824.         return;
  825.     if (self.health < 0)
  826.         return;
  827.  
  828.     if (self.waterlevel != 3)
  829.     {
  830.         if (self.air_finished < time)
  831.             sound (self, CHAN_VOICE, "player/gasp2.wav", 1, ATTN_NORM);
  832.         else if (self.air_finished < time + 9)
  833.             sound (self, CHAN_VOICE, "player/gasp1.wav", 1, ATTN_NORM);
  834.         self.air_finished = time + 12;
  835.         self.dmg = 2;
  836.     }
  837.     else if (self.air_finished < time)
  838.     {    // drown!
  839.         if (self.pain_finished < time)
  840.         {
  841.             self.dmg = self.dmg + 2;
  842.             if (self.dmg > 15)
  843.                 self.dmg = 10;
  844.             T_Damage (self, world, world, self.dmg);
  845.             self.pain_finished = time + 1;
  846.         }
  847.     }
  848.     
  849.     if (!self.waterlevel)
  850.     {
  851.         if (self.flags & FL_INWATER)
  852.         {    
  853.             // play leave water sound
  854.             sound (self, CHAN_BODY, "misc/outwater.wav", 1, ATTN_NORM);
  855.             self.flags = self.flags - FL_INWATER;
  856.         }
  857.         return;
  858.     }
  859.  
  860.     if (self.watertype == CONTENT_LAVA)
  861.     {    // do damage
  862.         if (self.dmgtime < time)
  863.         {
  864.             if (self.radsuit_finished > time)
  865.                 self.dmgtime = time + 1;
  866.             else
  867.                 self.dmgtime = time + 0.2;
  868.  
  869.             T_Damage (self, world, world, 10*self.waterlevel);
  870.         }
  871.     }
  872.     else if (self.watertype == CONTENT_SLIME)
  873.     {    // do damage
  874.         if (self.dmgtime < time && self.radsuit_finished < time)
  875.         {
  876.             self.dmgtime = time + 1;
  877.             T_Damage (self, world, world, 4*self.waterlevel);
  878.         }
  879.     }
  880.     
  881.     if ( !(self.flags & FL_INWATER) )
  882.     {    
  883.  
  884. // player enter water sound
  885.  
  886.         if (self.watertype == CONTENT_LAVA)
  887.             sound (self, CHAN_BODY, "player/inlava.wav", 1, ATTN_NORM);
  888.         if (self.watertype == CONTENT_WATER)
  889.             sound (self, CHAN_BODY, "player/inh2o.wav", 1, ATTN_NORM);
  890.         if (self.watertype == CONTENT_SLIME)
  891.             sound (self, CHAN_BODY, "player/slimbrn2.wav", 1, ATTN_NORM);
  892.  
  893.         self.flags = self.flags + FL_INWATER;
  894.         self.dmgtime = 0;
  895.     }
  896.     
  897.     if (! (self.flags & FL_WATERJUMP) )
  898.         self.velocity = self.velocity - 0.8*self.waterlevel*frametime*self.velocity;
  899. };
  900.  
  901. void() CheckWaterJump =
  902. {
  903.     local vector start, end;
  904.  
  905. // check for a jump-out-of-water
  906.     makevectors (self.angles);
  907.     start = self.origin;
  908.     start_z = start_z + 8; 
  909.     v_forward_z = 0;
  910.     normalize(v_forward);
  911.     end = start + v_forward*24;
  912.     traceline (start, end, TRUE, self);
  913.     if (trace_fraction < 1)
  914.     {    // solid at waist
  915.         start_z = start_z + self.maxs_z - 8;
  916.         end = start + v_forward*24;
  917.         self.movedir = trace_plane_normal * -50;
  918.         traceline (start, end, TRUE, self);
  919.         if (trace_fraction == 1)
  920.         {    // open at eye level
  921.             self.flags = self.flags | FL_WATERJUMP;
  922.             self.velocity_z = 225;
  923.             self.flags = self.flags - (self.flags & FL_JUMPRELEASED);
  924.             self.teleport_time = time + 2;    // safety net
  925.             return;
  926.         }
  927.     }
  928. };
  929.  
  930.  
  931. /*
  932. ================
  933. PlayerPreThink
  934.  
  935. Called every frame before physics are run
  936. ================
  937. */
  938. void() PlayerPreThink =
  939. {
  940.     local    float    mspeed, aspeed;
  941.     local    float    r;
  942.  
  943.     if (intermission_running)
  944.     {
  945.         IntermissionThink ();    // otherwise a button could be missed between
  946.         return;                    // the think tics
  947.     }
  948.  
  949.     if (self.view_ofs == '0 0 0')
  950.         return;        // intermission or finale
  951.  
  952.     makevectors (self.v_angle);        // is this still used
  953.  
  954.     CheckRules ();
  955.     WaterMove ();
  956.  
  957.     if (self.waterlevel == 2)
  958.         CheckWaterJump ();
  959.  
  960.     if (self.deadflag >= DEAD_DEAD)
  961.     {
  962.         PlayerDeathThink ();
  963.         return;
  964.     }
  965.     
  966.     if (self.deadflag == DEAD_DYING)
  967.         return;    // dying, so do nothing
  968.  
  969.     if (self.button2)
  970.     {
  971.         PlayerJump ();
  972.     }
  973.     else
  974.         self.flags = self.flags | FL_JUMPRELEASED;
  975.  
  976. // teleporters can force a non-moving pause time    
  977.     if (time < self.pausetime)
  978.         self.velocity = '0 0 0';
  979. };
  980.     
  981. /*
  982. ================
  983. CheckPowerups
  984.  
  985. Check for turning off powerups
  986. ================
  987. */
  988. void() CheckPowerups =
  989. {
  990.     if (self.health <= 0)
  991.         return;
  992.  
  993. // invisibility
  994.     if (self.invisible_finished)
  995.     {
  996. // sound and screen flash when items starts to run out
  997.         if (self.invisible_sound < time)
  998.         {
  999.             sound (self, CHAN_AUTO, "items/inv3.wav", 0.5, ATTN_IDLE);
  1000.             self.invisible_sound = time + ((random() * 3) + 1);
  1001.         }
  1002.  
  1003.  
  1004.         if (self.invisible_finished < time + 3)
  1005.         {
  1006.             if (self.invisible_time == 1)
  1007.             {
  1008.                 sprint (self, "Ring of Shadows magic is fading\n");
  1009.                 stuffcmd (self, "bf\n");
  1010.                 sound (self, CHAN_AUTO, "items/inv2.wav", 1, ATTN_NORM);
  1011.                 self.invisible_time = time + 1;
  1012.             }
  1013.             
  1014.             if (self.invisible_time < time)
  1015.             {
  1016.                 self.invisible_time = time + 1;
  1017.                 stuffcmd (self, "bf\n");
  1018.             }
  1019.         }
  1020.  
  1021.         if (self.invisible_finished < time)
  1022.         {    // just stopped
  1023.             self.items = self.items - IT_INVISIBILITY;
  1024.             self.invisible_finished = 0;
  1025.             self.invisible_time = 0;
  1026.         }
  1027.         
  1028.     // use the eyes
  1029.         self.frame = 0;
  1030.         self.modelindex = modelindex_eyes;
  1031.     }
  1032.     else
  1033.         self.modelindex = modelindex_player;    // don't use eyes
  1034.  
  1035. // invincibility
  1036.     if (self.invincible_finished)
  1037.     {
  1038. // sound and screen flash when items starts to run out
  1039.         if (self.invincible_finished < time + 3)
  1040.         {
  1041.             if (self.invincible_time == 1)
  1042.             {
  1043.                 sprint (self, "Protection is almost burned out\n");
  1044.                 stuffcmd (self, "bf\n");
  1045.                 sound (self, CHAN_AUTO, "items/protect2.wav", 1, ATTN_NORM);
  1046.                 self.invincible_time = time + 1;
  1047.             }
  1048.             
  1049.             if (self.invincible_time < time)
  1050.             {
  1051.                 self.invincible_time = time + 1;
  1052.                 stuffcmd (self, "bf\n");
  1053.             }
  1054.         }
  1055.         
  1056.         if (self.invincible_finished < time)
  1057.         {    // just stopped
  1058.             self.items = self.items - IT_INVULNERABILITY;
  1059.             self.invincible_time = 0;
  1060.             self.invincible_finished = 0;
  1061.         }
  1062.         if (self.invincible_finished > time)
  1063.             self.effects = self.effects | EF_DIMLIGHT;
  1064.         else
  1065.             self.effects = self.effects - (self.effects & EF_DIMLIGHT);
  1066.     }
  1067.  
  1068. // super damage
  1069.     if (self.super_damage_finished)
  1070.     {
  1071.  
  1072. // sound and screen flash when items starts to run out
  1073.  
  1074.         if (self.super_damage_finished < time + 3)
  1075.         {
  1076.             if (self.super_time == 1)
  1077.             {
  1078.                 sprint (self, "Quad Damage is wearing off\n");
  1079.                 stuffcmd (self, "bf\n");
  1080.                 sound (self, CHAN_AUTO, "items/damage2.wav", 1, ATTN_NORM);
  1081.                 self.super_time = time + 1;
  1082.             }      
  1083.             
  1084.             if (self.super_time < time)
  1085.             {
  1086.                 self.super_time = time + 1;
  1087.                 stuffcmd (self, "bf\n");
  1088.             }
  1089.         }
  1090.  
  1091.         if (self.super_damage_finished < time)
  1092.         {    // just stopped
  1093.             self.items = self.items - IT_QUAD;
  1094.             self.super_damage_finished = 0;
  1095.             self.super_time = 0;
  1096.         }
  1097.         if (self.super_damage_finished > time)
  1098.             self.effects = self.effects | EF_DIMLIGHT;
  1099.         else
  1100.             self.effects = self.effects - (self.effects & EF_DIMLIGHT);
  1101.     }    
  1102.  
  1103. // suit    
  1104.     if (self.radsuit_finished)
  1105.     {
  1106.         self.air_finished = time + 12;        // don't drown
  1107.  
  1108. // sound and screen flash when items starts to run out
  1109.         if (self.radsuit_finished < time + 3)
  1110.         {
  1111.             if (self.rad_time == 1)
  1112.             {
  1113.                 sprint (self, "Air supply in Biosuit expiring\n");
  1114.                 stuffcmd (self, "bf\n");
  1115.                 sound (self, CHAN_AUTO, "items/suit2.wav", 1, ATTN_NORM);
  1116.                 self.rad_time = time + 1;
  1117.             }
  1118.             
  1119.             if (self.rad_time < time)
  1120.             {
  1121.                 self.rad_time = time + 1;
  1122.                 stuffcmd (self, "bf\n");
  1123.             }
  1124.         }
  1125.  
  1126.         if (self.radsuit_finished < time)
  1127.         {    // just stopped
  1128.             self.items = self.items - IT_SUIT;
  1129.             self.rad_time = 0;
  1130.             self.radsuit_finished = 0;
  1131.         }
  1132.     }    
  1133.  
  1134. };
  1135.  
  1136.  
  1137. /*
  1138. ================
  1139. PlayerPostThink
  1140.  
  1141. Called every frame after physics are run
  1142. ================
  1143. */
  1144. void() PlayerPostThink =
  1145. {
  1146.     local    float    mspeed, aspeed;
  1147.     local    float    r;
  1148.  
  1149.     if (self.view_ofs == '0 0 0')
  1150.         return;        // intermission or finale
  1151.     if (self.deadflag)
  1152.         return;
  1153.         
  1154. // do weapon stuff
  1155.  
  1156.     W_WeaponFrame ();
  1157.  
  1158. // check to see if player landed and play landing sound    
  1159.     if ((self.jump_flag < -300) && (self.flags & FL_ONGROUND) && (self.health > 0))
  1160.     {
  1161.         if (self.watertype == CONTENT_WATER)
  1162.             sound (self, CHAN_BODY, "player/h2ojump.wav", 1, ATTN_NORM);
  1163.         else if (self.jump_flag < -650)
  1164.         {
  1165.             T_Damage (self, world, world, 5); 
  1166.             sound (self, CHAN_VOICE, "player/land2.wav", 1, ATTN_NORM);
  1167.             self.deathtype = "falling";
  1168.         }
  1169.         else
  1170.             sound (self, CHAN_VOICE, "player/land.wav", 1, ATTN_NORM);
  1171.  
  1172.         self.jump_flag = 0;
  1173.     }
  1174.  
  1175.     if (!(self.flags & FL_ONGROUND))
  1176.         self.jump_flag = self.velocity_z;
  1177.  
  1178.     CheckPowerups ();
  1179. };
  1180.  
  1181.  
  1182. /*
  1183. ===========
  1184. ClientConnect
  1185.  
  1186. called when a player connects to a server
  1187. ============
  1188. */
  1189. void() ClientConnect =
  1190. {
  1191.     bprint (self.netname);
  1192.     bprint (" entered the game\n");
  1193.     
  1194. // a client connecting during an intermission can cause problems
  1195.     if (intermission_running)
  1196.         ExitIntermission ();
  1197. };
  1198.  
  1199.  
  1200. /*
  1201. ===========
  1202. ClientDisconnect
  1203.  
  1204. called when a player disconnects from a server
  1205. ============
  1206. */
  1207. void() ClientDisconnect =
  1208. {
  1209.     if (gameover)
  1210.         return;
  1211.     // if the level end trigger has been activated, just return
  1212.     // since they aren't *really* leaving
  1213.  
  1214.     // let everyone else know
  1215.     bprint (self.netname);
  1216.     bprint (" left the game with ");
  1217.     bprint (ftos(self.frags));
  1218.     bprint (" frags\n");
  1219.     sound (self, CHAN_BODY, "player/tornoff2.wav", 1, ATTN_NONE);
  1220.     set_suicide_frame ();
  1221. };
  1222.  
  1223. /*
  1224. ===========
  1225. ClientObituary
  1226.  
  1227. called when a player dies
  1228. ============
  1229. */
  1230. void(entity targ, entity attacker) ClientObituary =
  1231. {
  1232.     local    float rnum;
  1233.     local    string deathstring, deathstring2;
  1234.     rnum = random();
  1235.  
  1236.     if (targ.classname == "player")
  1237.     {
  1238.         if (attacker.classname == "teledeath")
  1239.         {
  1240.             bprint (targ.netname);
  1241.             bprint (" was telefragged by ");
  1242.             bprint (attacker.owner.netname);
  1243.             bprint ("\n");
  1244.  
  1245.             attacker.owner.frags = attacker.owner.frags + 1;
  1246.             return;
  1247.         }
  1248.  
  1249.         if (attacker.classname == "teledeath2")
  1250.         {
  1251.             bprint ("Satan's power deflects ");
  1252.             bprint (targ.netname);
  1253.             bprint ("'s telefrag\n");
  1254.  
  1255.             targ.frags = targ.frags - 1;
  1256.             return;
  1257.         }
  1258.  
  1259.         if (attacker.classname == "player")
  1260.         {
  1261.             if (targ == attacker)
  1262.             {
  1263.                 // killed self
  1264.                 attacker.frags = attacker.frags - 1;
  1265.                 bprint (targ.netname);
  1266.                 
  1267.                 if (targ.weapon == 64 && targ.waterlevel > 1)
  1268.                 {
  1269.                     bprint (" discharges into the water.\n");
  1270.                     return;
  1271.                 }
  1272.                 if (targ.weapon == IT_GRENADE_LAUNCHER)
  1273.                     bprint (" tries to put the pin back in\n");
  1274.                 else
  1275.                     bprint (" becomes bored with life\n");
  1276.                 return;
  1277.             }
  1278.             else if ( (teamplay == 2) && (targ.team > 0)&&(targ.team == attacker.team) )
  1279.             {
  1280.                 if (rnum < 0.25)
  1281.                     deathstring = " mows down a teammate\n";
  1282.                 else if (rnum < 0.50)
  1283.                     deathstring = " checks his glasses\n";
  1284.                 else if (rnum < 0.75)
  1285.                     deathstring = " gets a frag for the other team\n";
  1286.                 else
  1287.                     deathstring = " loses another friend\n";
  1288.                 bprint (attacker.netname);
  1289.                 bprint (deathstring);
  1290.                 attacker.frags = attacker.frags - 1;
  1291.                 return;
  1292.             }
  1293.             else
  1294.             {
  1295.                 attacker.frags = attacker.frags + 1;
  1296.  
  1297.                 rnum = attacker.weapon;
  1298.                 if (rnum == IT_AXE)
  1299.                 {
  1300.                     deathstring = " was ax-murdered by ";
  1301.                     deathstring2 = "\n";
  1302.                 }
  1303.                 if (rnum == IT_SHOTGUN)
  1304.                 {
  1305.                     deathstring = " chewed on ";
  1306.                     deathstring2 = "'s boomstick\n";
  1307.                 }
  1308.                 if (rnum == IT_SUPER_SHOTGUN)
  1309.                 {
  1310.                     deathstring = " ate 2 loads of ";
  1311.                     deathstring2 = "'s buckshot\n";
  1312.                 }
  1313.                 if (rnum == IT_NAILGUN)
  1314.                 {
  1315.                     deathstring = " was nailed by ";
  1316.                     deathstring2 = "\n";
  1317.                 }
  1318.                 if (rnum == IT_SUPER_NAILGUN)
  1319.                 {
  1320.                     deathstring = " was punctured by ";
  1321.                     deathstring2 = "\n";
  1322.                 }
  1323.                 if (rnum == IT_GRENADE_LAUNCHER)
  1324.                 {
  1325.                     deathstring = " eats ";
  1326.                     deathstring2 = "'s pineapple\n";
  1327.                     if (targ.health < -40)
  1328.                     {
  1329.                         deathstring = " was gibbed by ";
  1330.                         deathstring2 = "'s grenade\n";
  1331.                     }
  1332.                 }
  1333.                 if (rnum == IT_ROCKET_LAUNCHER)
  1334.                 {
  1335.                     deathstring = " rides ";
  1336.                     deathstring2 = "'s rocket\n";
  1337.                     if (targ.health < -40)
  1338.                     {
  1339.                         deathstring = " was gibbed by ";
  1340.                         deathstring2 = "'s rocket\n" ;
  1341.                     }
  1342.                 }
  1343.                 if (rnum == IT_LIGHTNING)
  1344.                 {
  1345.                     deathstring = " accepts ";
  1346.                     if (attacker.waterlevel > 1)
  1347.                         deathstring2 = "'s discharge\n";
  1348.                     else
  1349.                         deathstring2 = "'s shaft\n";
  1350.                 }
  1351.                 bprint (targ.netname);
  1352.                 bprint (deathstring);
  1353.                 bprint (attacker.netname);
  1354.                 bprint (deathstring2);
  1355.             }
  1356.             return;
  1357.         }
  1358.         else
  1359.         {
  1360.             targ.frags = targ.frags - 1;
  1361.             bprint (targ.netname);
  1362.  
  1363.             // killed by a montser?
  1364.             if (attacker.flags & FL_MONSTER)
  1365.             {
  1366.                 if (attacker.classname == "monster_army")
  1367.                     bprint (" was shot by a Grunt\n");
  1368.                 if (attacker.classname == "monster_demon1")
  1369.                     bprint (" was eviscerated by a Fiend\n");
  1370.                 if (attacker.classname == "monster_dog")
  1371.                     bprint (" was mauled by a Rottweiler\n");
  1372.                 if (attacker.classname == "monster_dragon")
  1373.                     bprint (" was fried by a Dragon\n");
  1374.                 if (attacker.classname == "monster_enforcer")
  1375.                     bprint (" was blasted by an Enforcer\n");
  1376.                 if (attacker.classname == "monster_fish")
  1377.                     bprint (" was fed to the Rotfish\n");
  1378.                 if (attacker.classname == "monster_hell_knight")
  1379.                     bprint (" was slain by a Death Knight\n");
  1380.                 if (attacker.classname == "monster_knight")
  1381.                     bprint (" was slashed by a Knight\n");
  1382.                 if (attacker.classname == "monster_ogre")
  1383.                     bprint (" was destroyed by an Ogre\n");
  1384.                 if (attacker.classname == "monster_oldone")
  1385.                     bprint (" became one with Shub-Niggurath\n");
  1386.                 if (attacker.classname == "monster_shalrath")
  1387.                     bprint (" was exploded by a Vore\n");
  1388.                 if (attacker.classname == "monster_shambler")
  1389.                     bprint (" was smashed by a Shambler\n");
  1390.                 if (attacker.classname == "monster_tarbaby")
  1391.                     bprint (" was slimed by a Spawn\n");
  1392.                 if (attacker.classname == "monster_vomit")
  1393.                     bprint (" was vomited on by a Vomitus\n");
  1394.                 if (attacker.classname == "monster_wizard")
  1395.                     bprint (" was scragged by a Scrag\n");
  1396.                 if (attacker.classname == "monster_zombie")
  1397.                     bprint (" joins the Zombies\n");
  1398.  
  1399.                 return;
  1400.             }
  1401.  
  1402.             // tricks and traps
  1403.             if (attacker.classname == "explo_box")
  1404.             {
  1405.                 bprint (" blew up\n");
  1406.                 return;
  1407.             }
  1408.             if (attacker.solid == SOLID_BSP && attacker != world)
  1409.             {    
  1410.                 bprint (" was squished\n");
  1411.                 return;
  1412.             }
  1413.             if (attacker.classname == "trap_shooter" || attacker.classname == "trap_spikeshooter")
  1414.             {
  1415.                 bprint (" was spiked\n");
  1416.                 return;
  1417.             }
  1418.             if (attacker.classname == "fireball")
  1419.             {
  1420.                 bprint (" ate a lavaball\n");
  1421.                 return;
  1422.             }
  1423.             if (attacker.classname == "trigger_changelevel")
  1424.             {
  1425.                 bprint (" tried to leave\n");
  1426.                 return;
  1427.             }
  1428.  
  1429.             // in-water deaths
  1430.             rnum = targ.watertype;
  1431.             if (rnum == -3)
  1432.             {
  1433.                 if (random() < 0.5)
  1434.                     bprint (" sleeps with the fishes\n");
  1435.                 else
  1436.                     bprint (" sucks it down\n");
  1437.                 return;
  1438.             }
  1439.             else if (rnum == -4)
  1440.             {
  1441.                 if (random() < 0.5)
  1442.                     bprint (" gulped a load of slime\n");
  1443.                 else
  1444.                     bprint (" can't exist on slime alone\n");
  1445.                 return;
  1446.             }
  1447.             else if (rnum == -5)
  1448.             {
  1449.                 if (targ.health < -15)
  1450.                 {
  1451.                     bprint (" burst into flames\n");
  1452.                     return;
  1453.                 }
  1454.                 if (random() < 0.5)
  1455.                     bprint (" turned into hot slag\n");
  1456.                 else
  1457.                     bprint (" visits the Volcano God\n");
  1458.                 return;
  1459.             }
  1460.  
  1461.             // fell to their death?
  1462.             if (targ.deathtype == "falling")
  1463.             {
  1464.                 targ.deathtype = "";
  1465.                 bprint (" fell to his death\n");
  1466.                 return;
  1467.             }
  1468.  
  1469.             // hell if I know; he's just dead!!!
  1470.             bprint (" died\n");
  1471.         }
  1472.     }
  1473. };
  1474.